package com.sbtr.business.feature.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.sbtr.business.feature.entity.FeDuplicateRule;
import com.sbtr.business.feature.dto.FeDuplicateRuleDto;

import com.sbtr.business.feature.service.FeDuplicateRuleService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sbtr.business.feature.mapper.FeDuplicateRuleMapper;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.AbstractWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.sbtr.common.PageDto;
import com.sbtr.util.PageDtoUtils;
import org.springframework.transaction.annotation.Transactional;

/**
 * 重复值处理字段列表 Service接口实现类
 *
 * @author dgl
 * @since  2023-03-17
 */
@Transactional
@Service
public class FeDuplicateRuleServiceImpl extends ServiceImpl<FeDuplicateRuleMapper,FeDuplicateRule> implements FeDuplicateRuleService {

    @Autowired
    FeDuplicateRuleMapper feDuplicateRuleMapper;

    @Override
    public PageDto<FeDuplicateRule> pageList(FeDuplicateRuleDto feDuplicateRuleDto) {

        IPage<FeDuplicateRule> page = new Page<>();
        page.setSize(feDuplicateRuleDto.getPageSize());
        page.setCurrent(feDuplicateRuleDto.getPage());
        page = feDuplicateRuleMapper.selectPages(page, BeanUtil.beanToMap(feDuplicateRuleDto));
        PageDto<FeDuplicateRule> r = PageDtoUtils.getPageDtoByIPage(page, FeDuplicateRule.class);

        return r;
    }
}

